import requests
import json

def set_user_cookie(cookie_data):
    url = "http://127.0.0.1:3300/user/setCookie"  # 你的服务器地址
    headers = {"Content-Type": "application/json"}
    data = {"data": cookie_data}
    response = requests.post(url, headers=headers, data=json.dumps(data))
    if response.status_code == 200:
        result = response.json()
        if result["result"] == 100:
            print("User cookie has been set successfully.")
            print("Stored cookie:", cookie_data)  # 打印存储的 Cookie
        else:
            print("Failed to set user cookie:", result)
    else:
        print("Failed to set user cookie. HTTP Status Code:", response.status_code)

# 假设这里是你的用户 Cookie 字符串
user_cookie_data = "qq_domain_video_guid_verify=0572ccfe8fb71d4c; pgv_pvid=7514459580; _qimei_q36=; _qimei_h38=fded156bd15c06d8362ab92c02000005417b17; ptui_loginuin=2632740407; RK=gF39lAty7k; ptcz=4e0c227ec1180b8dc77feddbf4865128159cc539108aa1b235bbd21143d60dd4; fqm_pvqid=760c9673-a3b4-42ad-9ca2-7876a16dc944; ts_uid=376202578; tmeLoginType=2; music_ignore_pskey=202306271436Hn@vBj; wxrefresh_token=; psrf_qqopenid=BA2251B72AB9F5CF7DFA3AD7FDC96ED2; euin=NKCqoi4q7Kcs; qm_keyst=Q_H_L_63k3NVJkB4iRjsOTa1qUZ61bPUgBi3CU3orM9CdJABaoVDdlKiMuw6xbT0UUv48J4pMPB-yeB_Q; psrf_qqrefresh_token=8448FC9E47D30B780F6DE8508FE49EDA; wxopenid=; wxunionid=; qqmusic_key=Q_H_L_63k3NVJkB4iRjsOTa1qUZ61bPUgBi3CU3orM9CdJABaoVDdlKiMuw6xbT0UUv48J4pMPB-yeB_Q; psrf_musickey_createtime=1718206485; psrf_qqaccess_token=A44A487B421913EF5438544A69B125DB; uin=969359586; psrf_qqunionid=B47A35EE4695201B6E233283FA90AC2F; psrf_access_token_expiresAt=1725982485; fqm_sessionid=c52457c0-9eb8-4de3-a33b-af4fce7d3993; pgv_info=ssid=s2751435200; ts_last=y.qq.com/; ts_refer=cn.bing.com/"

# 调用设置用户 Cookie 的函数
set_user_cookie(user_cookie_data)
